The present invention relates generally to computer systems and devices that execute programs written in object oriented computer languages such as Java, and particularly to a system and method for preloading a set of classes in such a device.
In computer systems that execute Java programs, or programs in other object-oriented languages that support runtime program linking, the set of computer programs to be executed is dynamically determined, loaded and linked at run time. While this is very flexible, and makes it particularly easy to use software loaded from remotely located computers, the loading and linking of a basic set of class files needed to support basic data processing operations can be time consuming, and expensive in terms of memory resources, especially in small client devices whose computational power and memory resources are much more limited than typical desktop computers.
This problem is addressed in U.S. Pat. No. 5,815,718, issued Sep. 9, 1998 to Theron Tock and assigned to Sun Microsystems, Inc. The ""718 patent is particularly focused on preloading class files into read only memory (ROM), for use in client devices having very limited read/write memory resources. Such devices use ROM to store a significant portion of their software.
The present invention is directed to related but somewhat different problemxe2x80x94preloading class files into a client device that does not have a virtual memory manager. Another problem addressed by the present invention is how to rearrange the data structures of a virtual machine (e.g., a Java program verifier, class loader, interpreter and associated security procedures) so that they can be executed in a client device that limits the maximum size of any one data structure. For instance, the maximum size of a resource may be 64K bytes.
An authoring system prepares a specified set of classes for preloading in client devices lacking a virtual memory manager. The authoring system converts the specified set of classes into a plurality of resource modules, a subset of the resource modules each including items that have pointers to items in other ones of the resource modules. The authoring system generates a load module, for loading into the client devices, that includes the plurality of resource modules, an interpreter and a startup procedure. The interpreter is for executing, on the client devices, programs in a predefined computer language. The specified set of classes includes methods in the predefined computer language. The startup procedure is for execution by the client devices when loading the interpreter for execution. The startup procedure replaces pointers in the resource modules with updated pointers in accordance with actual memory locations of the resource modules in any particular one the client devices.
Another aspect of the present invention is a client device having a data processing unit, a user interface and memory for storing an operating system, lacking a virtual memory manager, as well as the aforementioned resource modules, the interpreter and startup procedure.
In an embodiment of the invention, the resource modules include a class table resource module, a method table resource module, a field table resource module, a constant pool resource module and a string resource module. The class data structure includes pointers to items in the method table, field table and constant pool resource modules, the field table resource module includes pointers to items in the string resource module, and the constant pool resource module includes pointers to items in the field table resource module and items in the string resource module.
In an embodiment of the invention, the startup procedure includes instructions for positioning a first data structure in each of at least two of the resource modules in the subset at a 0 mod 4 address within any particular one of the client devices.
In an embodiment of the invention, resource modules include a table of contents indicating a memory address for each of a second subset of the resource modules, the second subset including those of the resource modules pointed to by at least one of the pointers in the resource modules. The startup procedure includes instructions for (A) determining a current memory address for each of the resource modules in the second subset, determining a differential value for each resource modules in the second subset corresponding to a difference between the current memory address and the memory address indicated in the table the table of contents, and (B) adjusting at least a subset of the pointers in the resource modules in accordance with the differential values.
In an embodiment of the invention, the resource modules include a methods table module having pointers to code for methods of the specified set of classes, and a subset of the pointers in the methods table point to native methods in the compiled interpreter.